﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace InsertKickItButtonPlugin {
    public partial class KickItForm : Form {

        public string CodeSnippet {
            get {
                return this.txtCodeSnippet.Text;
            }
        }

        public KickItForm( ) {
            InitializeComponent( );
        }

        private void KickItForm_Load( object sender, EventArgs e ) {
            InsertNewButtonHTML( );
        }

        private void InsertNewButtonHTML( ) {
            string newArticleHTML = "<a href=\"http://www.dotnetkicks.com/submit/\" target=\"_blank\">" +
                                     "  <img src=\"http://www.dotnetkicks.com/Services/Images/KickItImageGenerator.ashx\" border=\"0\" alt=\"kick it on DotNetKicks.com\" /> " +
                                     "</a>";
            this.txtCodeSnippet.Text = newArticleHTML;
            this.txtCodeSnippet.SelectionStart = 0;
        }

        private void btnInsert_Click( object sender, EventArgs e ) {
            this.DialogResult = DialogResult.OK;
        }

        private void btnCancel_Click( object sender, EventArgs e ) {
            this.DialogResult = DialogResult.Cancel;
        }

        private void linkLabel1_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e ) {
            System.Diagnostics.Process.Start( "http://www.dotnetkicks.com" );
        }

        private void chkArticleSubmitted_CheckedChanged( object sender, EventArgs e ) {
            if (this.chkArticleSubmitted.Checked) {
                this.pnlInstructions.Visible = true;
                this.txtCodeSnippet.Text = "";
            } else {
                this.pnlInstructions.Visible = false;
                InsertNewButtonHTML( );
            }
        }


    }
}
